/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FeedbackDetailofManager.java
 *
 * Created on Dec 14, 2009, 10:36:19 AM
 */

package GUI;
import DatabaseAccess.D_DBHelper;
import java.awt.Color;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import java.util.Vector;
import java.sql.ResultSet;
/**
 *
 * @author TienDung
 */
public class FeedbackDetailofManager extends javax.swing.JDialog {

    /** Creates new form FeedbackDetailofManager */
    D_DBHelper db= null;
    private ResultSet rs;
    public FeedbackDetailofManager(java.awt.Frame parent, boolean modal, int comID, int Type1, int Type2) {
        super(parent, modal);
        initComponents();
        db = new D_DBHelper();
        try {
            db.setConnectionUrl("connection.cfg");
        } catch (SQLException ex) {
            Logger.getLogger(AddNewFeedback.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(!db.setupConnection()){
            JOptionPane.showMessageDialog(null,"Can not open the connection","Connection Dialog",JOptionPane.ERROR_MESSAGE);
        }
        
        setForm(comID, Type1, Type2);
        txtDepartment.setBackground(Color.WHITE);
        txtDispatchNo.setBackground(Color.WHITE);
        txtDueDate.setBackground(Color.WHITE);
        txtProduct.setBackground(Color.WHITE);
        txtStaff.setBackground(Color.WHITE);
        txtStartDate.setBackground(Color.WHITE);
        txtTitle.setBackground(Color.WHITE);
        txtTransferDate.setBackground(Color.WHITE);
    }

    public void setForm(int comID, int Type1, int Type2){
        //System.out.println(comID+","+Type_1+","+Type_2);
        
        Vector v=new Vector();
        v.add(comID);
        v.add(Type1);
        v.add(Type2);
        try {
            rs = db.executeProcedure("ManagerDisplayFeedbackDetail", v);
            if(Type1==1 && Type2==1){
                rs.next();
                //System.out.println(rs.getString(2));
                txtTitle.setText(rs.getString(2));
                txaContent.setText(rs.getString(6));
                txtDispatchNo.setText(rs.getString(1));
                txtProduct.setText(rs.getString(3));
                txtStartDate.setText(rs.getString(8));
                txtDueDate.setText(rs.getString(10));
                txaContentResponse.setText(rs.getString(7));
                txtTransferDate.setText(rs.getString(9));
                txtDepartment.setText(rs.getString(4));
                txtStaff.setText(rs.getString(5));
            }
            else if(Type1==0 && Type2==1){
                rs.next();
                txtTitle.setText(rs.getString(2));
                txaContent.setText(rs.getString(3));
                txtDispatchNo.setText(rs.getString(1));
                txtProduct.setText(rs.getString(4));
                txtStartDate.setText(rs.getString(6));
                txtTransferDate.setText(rs.getString(7));
                txtDepartment.setText(rs.getString(5));
            }
        } catch (SQLException ex) {
            Logger.getLogger(FeedbackDetailofManager.class.getName()).log(Level.SEVERE, null, ex);
        }

        

    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel21 = new javax.swing.JPanel();
        jPanel22 = new javax.swing.JPanel();
        jLabel45 = new javax.swing.JLabel();
        txtTitle = new javax.swing.JTextField();
        jLabel46 = new javax.swing.JLabel();
        jLabel47 = new javax.swing.JLabel();
        txtDispatchNo = new javax.swing.JTextField();
        jLabel48 = new javax.swing.JLabel();
        txtProduct = new javax.swing.JTextField();
        jLabel49 = new javax.swing.JLabel();
        txtStartDate = new javax.swing.JTextField();
        jLabel50 = new javax.swing.JLabel();
        txtDueDate = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txaContent = new javax.swing.JTextArea();
        jPanel23 = new javax.swing.JPanel();
        jLabel51 = new javax.swing.JLabel();
        jScrollPane12 = new javax.swing.JScrollPane();
        txaContentResponse = new javax.swing.JTextArea();
        jLabel52 = new javax.swing.JLabel();
        jLabel53 = new javax.swing.JLabel();
        txtStaff = new javax.swing.JTextField();
        txtDepartment = new javax.swing.JTextField();
        btnCancel = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        txtTransferDate = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setResizable(false);

        jPanel21.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED), "Feedback Detail", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 3, 18))); // NOI18N

        jPanel22.setBorder(javax.swing.BorderFactory.createTitledBorder("Feedback of customer"));

        jLabel45.setText("Title");

        txtTitle.setEditable(false);
        txtTitle.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtTitle.setPreferredSize(new java.awt.Dimension(200, 20));

        jLabel46.setText("Content");

        jLabel47.setText("Dispatch no");

        txtDispatchNo.setEditable(false);
        txtDispatchNo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtDispatchNo.setPreferredSize(new java.awt.Dimension(100, 20));

        jLabel48.setText("Product");

        txtProduct.setEditable(false);
        txtProduct.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtProduct.setPreferredSize(new java.awt.Dimension(100, 20));

        jLabel49.setText("Start date");

        txtStartDate.setEditable(false);
        txtStartDate.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

        jLabel50.setText("Due date");

        txtDueDate.setEditable(false);
        txtDueDate.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N

        txaContent.setColumns(20);
        txaContent.setEditable(false);
        txaContent.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txaContent.setRows(5);
        jScrollPane1.setViewportView(txaContent);

        javax.swing.GroupLayout jPanel22Layout = new javax.swing.GroupLayout(jPanel22);
        jPanel22.setLayout(jPanel22Layout);
        jPanel22Layout.setHorizontalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel45)
                    .addComponent(jLabel46))
                .addGap(28, 28, 28)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1)
                    .addComponent(txtTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(55, 55, 55)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel48)
                    .addComponent(jLabel47)
                    .addComponent(jLabel49)
                    .addComponent(jLabel50))
                .addGap(61, 61, 61)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtDueDate)
                    .addComponent(txtStartDate)
                    .addComponent(txtProduct, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(txtDispatchNo, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel22Layout.setVerticalGroup(
            jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel22Layout.createSequentialGroup()
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel45)
                        .addComponent(txtTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel47))
                    .addComponent(txtDispatchNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
                        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtProduct, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel48))
                        .addGap(11, 11, 11)
                        .addComponent(jLabel46)
                        .addGap(10, 10, 10)
                        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtStartDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel49))
                        .addGap(34, 34, 34)
                        .addGroup(jPanel22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDueDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel50)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel22Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(11, 11, 11))))
        );

        jPanel23.setBorder(javax.swing.BorderFactory.createTitledBorder("Reply of Company"));

        jLabel51.setText("Content");

        txaContentResponse.setColumns(20);
        txaContentResponse.setEditable(false);
        txaContentResponse.setFont(new java.awt.Font("Tahoma", 1, 13)); // NOI18N
        txaContentResponse.setRows(5);
        jScrollPane12.setViewportView(txaContentResponse);

        jLabel52.setText("Department");

        jLabel53.setText("Staff");

        txtStaff.setEditable(false);
        txtStaff.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtStaff.setPreferredSize(new java.awt.Dimension(150, 20));

        txtDepartment.setEditable(false);
        txtDepartment.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtDepartment.setPreferredSize(new java.awt.Dimension(150, 20));

        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/GUI/Icon/cancel.png"))); // NOI18N
        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        jLabel1.setText("Transfer Date");

        txtTransferDate.setEditable(false);
        txtTransferDate.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txtTransferDate.setPreferredSize(new java.awt.Dimension(200, 20));

        javax.swing.GroupLayout jPanel23Layout = new javax.swing.GroupLayout(jPanel23);
        jPanel23.setLayout(jPanel23Layout);
        jPanel23Layout.setHorizontalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel23Layout.createSequentialGroup()
                        .addComponent(jLabel51)
                        .addGap(30, 30, 30)
                        .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(55, 55, 55)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel53)
                            .addComponent(jLabel52)
                            .addComponent(jLabel1))
                        .addGap(65, 65, 65)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtTransferDate, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                            .addComponent(txtDepartment, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)
                            .addComponent(txtStaff, javax.swing.GroupLayout.DEFAULT_SIZE, 172, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup()
                        .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(257, 257, 257)))
                .addGap(52, 52, 52))
        );
        jPanel23Layout.setVerticalGroup(
            jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel23Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel51)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel23Layout.createSequentialGroup()
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(txtTransferDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtDepartment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel52))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel23Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel53)
                            .addComponent(txtStaff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                .addComponent(btnCancel)
                .addGap(24, 24, 24))
        );

        javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
        jPanel21.setLayout(jPanel21Layout);
        jPanel21Layout.setHorizontalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addGroup(jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel21Layout.setVerticalGroup(
            jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel21Layout.createSequentialGroup()
                .addComponent(jPanel22, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel21, javax.swing.GroupLayout.DEFAULT_SIZE, 715, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        // TODO add your handling code here:
        dispose();
}//GEN-LAST:event_btnCancelActionPerformed

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel45;
    private javax.swing.JLabel jLabel46;
    private javax.swing.JLabel jLabel47;
    private javax.swing.JLabel jLabel48;
    private javax.swing.JLabel jLabel49;
    private javax.swing.JLabel jLabel50;
    private javax.swing.JLabel jLabel51;
    private javax.swing.JLabel jLabel52;
    private javax.swing.JLabel jLabel53;
    private javax.swing.JPanel jPanel21;
    private javax.swing.JPanel jPanel22;
    private javax.swing.JPanel jPanel23;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane12;
    private javax.swing.JTextArea txaContent;
    private javax.swing.JTextArea txaContentResponse;
    private javax.swing.JTextField txtDepartment;
    private javax.swing.JTextField txtDispatchNo;
    private javax.swing.JTextField txtDueDate;
    private javax.swing.JTextField txtProduct;
    private javax.swing.JTextField txtStaff;
    private javax.swing.JTextField txtStartDate;
    private javax.swing.JTextField txtTitle;
    private javax.swing.JTextField txtTransferDate;
    // End of variables declaration//GEN-END:variables

}
